package rahmath.sharif.docrypt.entity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.UUID;

public class Vault implements Serializable {
	private static final long serialVersionUID = 1L;
	private String name;
	private String vaultFileName;
	private String password;
	private HashMap<String, Data> datas;

	public Vault() {
		this.vaultFileName = UUID.randomUUID().toString();
		this.datas = new HashMap<String, Data>();
	}

	public Vault(String name) {
		this();
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getVaultFileName() {
		return vaultFileName;
	}

	public void setVaultFileName(String vaultFileName) {
		this.vaultFileName = vaultFileName;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public HashMap<String, Data> getDatas() {
		return datas;
	}

	public void setDatas(HashMap<String, Data> datas) {
		this.datas = datas;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((datas == null) ? 0 : datas.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Vault other = (Vault) obj;
		if (datas == null) {
			if (other.datas != null)
				return false;
		} else if (!datas.equals(other.datas))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return this.name;
	}
}
